package com.local.web.service.impl;

import com.local.common.constants.BusinessException;
import com.local.common.util.ResultUtil;
import com.local.goods.feign.GoodsServiceFeign;
import com.local.goods.pojo.GoodsCategory;
import com.local.web.service.GoodsCategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class GoodsCategoryServiceImpl implements GoodsCategoryService {

    @Autowired
    private GoodsServiceFeign goodsServiceFeign;

    @Override
    public List<GoodsCategory> getIndexCategoryList() {
        ResultUtil<List<GoodsCategory>> indexCategoryListResult = goodsServiceFeign.getIndexCategoryList();
        if (indexCategoryListResult.getCode() != 200) {
            throw new BusinessException(indexCategoryListResult.getCode(), indexCategoryListResult.getMessage());
        }

        List<GoodsCategory> data = indexCategoryListResult.getData();
        return data;
    }
}
